/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.its.desarrollosw2.dao;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import mx.its.desarrollosw2.Categoria;

/**
 *
 * @author sistemas
 */
@Stateless
public class CategoriaDao extends AbstractDao<Categoria> implements CategoriaDaoLocal {
    @PersistenceContext(unitName = "Biblioteca8EE-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public CategoriaDao() {
        super(Categoria.class);
    }
    @Override
       public boolean  findDuplicity(Categoria category){
       Query q=em.createNamedQuery("Categoria.findDuplicity"); 
       q.setParameter("clave", category.getClave());
       q.setParameter("descripcion",category.getDescripcion());
       q.setParameter("color",category.getColor());
       return !q.getResultList().isEmpty();
    }
}
